﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
     
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false; //加载时 取消跨线程检查
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread t1 = new Thread(new ThreadStart(RabbitRun));
            Thread t2 = new Thread(new ThreadStart(TurtleRun));
            t1.Start();
            t2.Start();
        }
      
        public void RabbitRun()
        {
               
                    for (int i = 0; i < 600; i++)
                    {
                        Thread.Sleep(100);
                        pictureBox1.Location = new Point(pictureBox1.Location.X + 3, pictureBox1.Location.Y);
                        if (i == 20 * 3)
                        {
                            Thread.Sleep(35000);
                        }
                        else if (pictureBox1.Location.X >= label2.Location.X)
                        {
                            break;
                        }

                    }
        
        }

        public void TurtleRun()
        {
           
                for (int j = 0; j < 600; j++)
                {
                    Thread.Sleep(100);
                    pictureBox2.Location = new Point(pictureBox2.Location.X + 1, pictureBox2.Location.Y);

                    if (pictureBox2.Location.X >= label2.Location.X)
                    {
                        break;
                    }

                }
            
            

        }

    }
}
